package org.hpin.asset.service;

import org.hpin.asset.dao.AssetinfoDao;
import org.hpin.asset.entity.Assetinfo;
import org.hpin.common.core.orm.BaseEntity;
import org.hpin.common.core.orm.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service(value = "org.hpin.asset.service.AssetinfoService")
@Transactional(rollbackFor = Exception.class)
public class AssetinfoService extends BaseService {
	@Autowired
	private AssetinfoDao assetinfoDao;
	
	@Override
	public void save(BaseEntity baseEntity) {
		super.save(baseEntity);
	}
	
	/**
	 * 删除多个资产
	 * @param ids
	 */
	
	
	public void delete(String [] ids){
		for(int i=0;i< ids.length;i++){
			Assetinfo assetinfo = (Assetinfo) assetinfoDao.findById(Assetinfo.class,ids[i]);
			assetinfo.setIsDeleted(1);
			assetinfoDao.update(assetinfo);
		}
	}
	/**
	 * 根据id删除资产
	 * @param id
	 */
	public void deleteById(String id){
			Assetinfo assetinfo = (Assetinfo) assetinfoDao.findById(Assetinfo.class,id);
			assetinfo.setIsDeleted(1);
			assetinfoDao.update(assetinfo);
	}

}
